home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / hdf / unix / examples.lha / examples / ann / gen2Dfloat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-13  |  1.3 KB  |  58 lines

  1. #ifdef RCSID
  2. static char RcsId[] = "@(#)$Revision: 1.1 $";
  3. #endif
  4. /*
  5. $Header: /pita/work/HDF/dev/RCS/test/annotations/gen2Dfloat.c,v 1.1 90/04/19 11:12:56 mfolk beta $
  6.  
  7. $Log:    gen2Dfloat.c,v $
  8.  * Revision 1.1  90/04/19  11:12:56  mfolk
  9.  * Initial revision
  10.  * 
  11. */
  12. #include <stdio.h>
  13. #include <math.h>
  14.  
  15. /****************************************************************
  16. **
  17. **  gen2Dfloat:  generate 2-D data array for turning into image
  18. **               plus max, min, and cross-hatching
  19. **
  20. ****************************************************************/
  21.     int
  22. gen2Dfloat(height, width, data,  max, min)
  23. int   height, width;
  24. float *data, *max, *min;
  25. {
  26.     int i, j, gap;
  27.     float *pdata;
  28.  
  29.     *min = 0.0;
  30.     *max = height;
  31.  
  32.     /* store one value per row, increasing by one for each row */
  33.     pdata = data;
  34.     for (i=0; i< height; i++)
  35.        for (j=0; j< width; j++) 
  36.            *pdata++ = (float) i+1;
  37.  
  38.     /* generate cross-hatching -- one row/col of 0's every 10th row/col */
  39.     /* rows */
  40.     pdata = data;
  41.     gap = height/10;
  42.     for (i=0; i<height; i += gap) {
  43.         pdata = data + i*width;
  44.            for (j=0; j<width; j++)
  45.             *pdata++ = 0.0;
  46.     }
  47.     /* cols */
  48.     pdata = data;
  49.     gap = width/10;
  50.     for (i=0; i<height; i++) {
  51.         pdata = data + i*width;
  52.         for (j=0; j<width; j += gap, pdata += gap) {
  53.             *pdata = 0.0;
  54.         }
  55.     }
  56. }
  57.  
  58.